Foreground-Background Separation With Codebook Model